package yxy.game.pm2.module.friend;

import yxy.game.pm2.bean.PlayerBean;
import yxy.game.pm2.message.FriendMessage;
import yxy.game.pm2.message.PlayerMessage;
import yxy.game.pm2.module.player.PlayerHandle;

public class FriendHandle {

	public FriendMessage.Friend packFriend(FriendModule friendModule, String friendCode) {
		PlayerBean playerBean = PlayerBean.get(friendCode);
		PlayerMessage.PlayerSimpleInfo.Builder builder = new PlayerHandle().playerSimpleInfo(playerBean);
		builder.setOnline(playerBean.online());

		FriendMessage.Friend.Builder friend = FriendMessage.Friend.newBuilder();
		friend.setInfo(builder);
		friend.setGiven(friendModule.getGiven().contains(friendCode));
		friend.setGift(friendModule.getGiftn().contains(friendCode));

		return friend.build();
	}

}
